﻿#include<iostream>
#include<string>
#include<Windows.h>
#include <ctime>
#include <memory>
#include "Enemy.h"
#include "startPage.h"
#include "loadPage.h"
#include "Save.h"
#include "simpleStruct.h"
#include "color_print.h"
#include "title_print.h"
#pragma comment(lib, "winmm.lib")
using namespace std;
void welcome() {
	system("color 04");
	title_print();
	string s1("欢迎来到本游戏,请选择你要干什么");
	const char* newGameMenu = "1.新的游戏   2.读取存档   3.退出游戏";
	COLOR_PRINT(s1, 2, 20);
	COLOR_PRINT(newGameMenu, 11);

	int choice ;
	cin >> ws;
	//cin >> choice;
	while (true) {
		if (cin >> choice) {
			if (choice == 1 || choice == 2 || choice == 3) {
				break;
			}
			else {
				const char* cinError = "输入错误，请重新输入";
				COLOR_PRINT(cinError, 4);
				cin.get();
				cin >> choice;
			}
		}
		else {
			cin.clear();
			char ch;
			cin.get(ch);
			const char* cinError = "输入错误，请重新输入";
			COLOR_PRINT(cinError, 4);
		}
	}
	switch (choice) {
	case 1: {
		startPage::loadPage();
		break;
	}
	case 2: {
	
		Hero hero;
		roomPage room;
		Save::loadHero(hero);
		Save::loadRoom(room);
		Page* fp = &room;
		load(*fp, hero);
		delete fp;
		break;
	}
	case 3:
		break;
	default:
		break;
	}
}
int main() {
	srand(time(0));
	mciSendString(L"open .\\music\\大地图.mp3", nullptr, 0, nullptr);
	mciSendString(L"play .\\music\\大地图.mp3", nullptr, 0, nullptr);

	welcome();

	mciSendString(L"stop .\\music\\大地图.mp3", nullptr, 0, nullptr);
	return 0;
}